import java.util.Scanner;

public class P1980 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int x=sc.nextInt();
        int count=0;
        int b,c;
        for (int i = 1; i <= n; i++) {
            b=i;
            while (b != 0) {
                c=b%10;
                b=b/10;
                if(c==x)
                    count++;
            }
        }

        System.out.println(count);
    }
}
